<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


<title>POS收单运营管理平台</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link href="<s:url value="/css/common.less"/>" type="text/less"
	rel="stylesheet" />
	<link href="<s:url value="/css/common.css"/>" type="text/css"
	rel="stylesheet" />

<script type="text/javascript"
	src="<s:url value="/js/jquery-1.3.2.js" />"></script>
<script type="text/javascript"
	src="<s:url value="/js/jquery-1.9.1.js" />"></script>
<script type="text/javascript"
	src="<s:url value="/js/jquery.blockUI.js" />"></script>
<script type="text/javascript"
	src="<s:url value="/js/jquery.validate.min.js" />"></script>
<script type="text/javascript"
	src="<s:url value="/js/pwms.validate.js?v13" />"></script>
<script language="javascript" type="text/javascript"
	src="<s:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>

<style type="text/css">

.error {
	color: red;
}

</style>
<script type="text/javascript">

	$(document).ready(function() {
		//检查是什么状态，更新或新增
		var flag="${flag}";
		if(flag=="update"){
			$("#blackForm").attr("action","<%=basePath%>/blacklist/updateBlacklist.ct");
		}
		loadType();
		$('#type').change(function(){
			loadType();			
		});
		function loadType()
		{
			var type=$('#type').val();
			if(type=='C')
			{
				$('#title').text("卡号：");
				}
			else if(type=='M')
				{
				  $('#title').text("商户号：");
				}
			else if(type=='D')
			{
				$('#title').text('法人身份证号:');
			}
			else if(type=='N')
			{
				$('#title').text('非法人身份证号:');
			}
			else if(type=='P')
			{
				$('#title').text('手机号:');
			}
			else if(type=='O')
			{
				$('#title').text('营业执照号码:');
			}
			else{
				$('#title').text('号码:');
			}
		}
		// 字符最大长度验证（一个中文字符长度为2）
		jQuery.validator.addMethod("stringMaxLength", function(value,element, param) {
			var length = value.length;
			for ( var i = 0; i < value.length; i++) {
				if (value.charCodeAt(i) > 127) {
					length++;
				}
			}
			return this.optional(element) || (length <=param);
		}, $.validator.format("长度不能大于{0}!"));	
		$("#blackForm").validate({
			debug : true,
			submitHandler : function(form) {
				$("#btnAdd").attr("disabled",true);
					form.submit();
			},
			rules : {
				"black.status" : {required : true},
				"black.date" : {required : true},				 
				"black.time" : {required : true},
				"black.blackType" : {required : true},
				"black.reason" : {required : true,stringMaxLength:100},
				"black.status" : {required : true},
				"black.blackNum" : {required : true,stringMaxLength:30,remote:{
						type:'post',
						url:'validateBlackNum.ct',
						data:{
							"black.blackNum":function()
							{
								return $('#blackNum').val();
							}
						}
					}
				}																																	
			},
			messages : {
				"black.status" : {required : "必选"},
				"black.date" : {required : "必填"},				 
				"black.time" : {required : "必填"},
				"black.blackType" : {required : "必选"},
				"black.blackNum" : {required : "必填",remote:"卡号或商户号已存在"},
				"black.status" : {required : "必选"},
				"black.reason" : {required : "必填"}
			},errorPlacement: function(error, element) { 
			    if ( element.is(":radio") ) 
			        error.appendTo ( element.parent() ); 
			    else if ( element.is(":checkbox") ) 
			        error.appendTo ( element.parent() ); 
			    else if ( element.is("input") ) {
			    	error.appendTo ( element.parent() ); 
			    }
			    else 
			        error.insertAfter(element); 
			} 

		});
		
	});

</script>



</head>

<body>
			<s:form id="blackForm" action="/blacklist/addblack.ct" method="post"  theme="simple"  >
				<table width="100%" class="tb" >
			        <tr class="tb-line">
			            <td class="tb-td" colspan="6">
				            <div class="tb-h2">POS收单运营管理平台</div>
					   	</td>
			        </tr>
	                <tr class="tb-line bg-gray">
			            <td class="tb-td" colspan="4"><div class="tb-h3"><s:if test="#request.flag ==\"update\"">
			                	修改黑名单 
			                	</s:if>
			                	<s:else>
			                	添加黑名单
			                	</s:else></div></td>
			        </tr>
			
					<tr class="tb-line">

						
				    	<td align="right" class="tb-td" style="width:110px;">
				        	<div class="tb-h4">日期：</div>
			            </td>
			            <td class="tb-td" >
			             	<label class="tb-input-lengthen"> 
			             		<s:textfield name="date" theme="simple" cssClass="queryWidth" disabled="true" value="%{black.date}"/> 
			             		<s:hidden name="black.date"></s:hidden>
			             	</label>
			             	<font color="red">*</font>
			             </td>
			             <td align="right" class="tb-td" style="width:110px;">
				        	<div class="tb-h4">时间：</div>
			            </td>
			            <td class="tb-td" >
			             	<label class="tb-input-lengthen"> 
			             		<s:textfield name="time" theme="simple" cssClass="queryWidth" disabled="true" value="%{black.time}"/>  
			             		<s:hidden name="black.time"></s:hidden>
			             	</label>
			             	<font color="red">*</font>
			             </td>
					</tr>
					<tr class="tb-line">
				    	<td align="right" class="tb-td" style="width:110px;">
				        	<div class="tb-h4">类型：</div>
			            </td>
			            <td class="tb-td" >
			             	<label class="tb-select">
								<s:select name="black.blackType" list="#{'C':'黑卡','M':'黑商户','D':'法人身份证','N':'非法人身份证','P':'手机号','O':'营业执照' }"  listKey="key" listValue="value" id="type"   cssClass="queryWidth" />
						 	</label>
						 	<font color="red">*</font>
						</td>
					     
				    	<td align="right" class="tb-td" style="width:110px;">
				        	<div class="tb-h4" id="title">卡号或商户号：</div>
			            </td>
			            <td class="tb-td" >			             	
								<s:if test="#request.flag ==\"update\"">
								<label class="tb-input-lengthen">
								<s:textfield maxLength="200" theme="simple" cssClass="queryWidth" disabled="true" value="%{black.blackNum}"></s:textfield>	
								</label>
								</s:if>
								<s:else>
								<label class="tb-input-lengthen">
			             		<s:textfield maxLength="200" name="black.blackNum"
									cssClass="queryWidth" id="blackNum"></s:textfield>
								</label>
								</s:else>
								<s:hidden name="blackNum" value="%{black.blackNum}"></s:hidden>
								<font color="red">*</font>
						</td>
						</tr>
						<s:if test="#request.flag ==\"update\"">
						<tr class="tb-line">					
				    	<td align="right" class="tb-td" style="width:110px;">
				        		<div class="tb-h4">状态：</div>
			            </td>
			            <td class="tb-td" >
			             		<s:radio name="black.status" list="#{'1':'冻结','0':'解禁'}"></s:radio>
						 </td>
						<td colspan="2"></td>
						</tr>	
						</s:if>			   
					<tr class="tb-line">
				    	<td align="right" class="tb-td" style="width:110px;">
				        	<div class="tb-h4">原因：</div>
			            </td>
			            <td class="tb-td" colspan="3" style="height:auto;line-height:auto;" >
			             	<label style="height:auto;line-height:auto;">
			             		<s:textarea rows="5" cssClass="someWidth" 
								name="black.reason" maxlength="200"  style="height: 102px; resize: none; width: 530px;padding:0 5px;" />
			             	</label>
			             </td>
					</tr>
				</table>		
		      <table width="100%" border="0" cellspacing="0" class="table">
		           	<tr class="tb-line">
						<td colspan="4" align="center"><span style="color: red"><s:actionerror /></span>
							<span style="color: red;"><s:actionmessage /></span > <span style="color: red;"><s:fielderror
									cssClass="fieldError" /></span>
							<span id="otherError"></span>
						</td>
					</tr>
					<tr class="tb-line">
			            <td class="tb-td line-submit" align="center" colspan="4">
			                <label class="tb-input-submit">		                
			                	<s:submit id="btnAdd" value="保  存" />								
							</label>
			                <label class="tb-input-submit">
								<input type="reset" value="取  消"/>
							</label>
							<label class="tb-input-submit">
								<input type="button" value="返回" onclick="history.back()"/>
							</label>
						</td>
					</tr>
            </table>
			</s:form>	
</body>
</html>
